let loadingCount = 0

/**
 * 显示加载
 * @param {string} title "加载中"
 * @param {boolean} mask ture
 */
const showLoading = (title = '加载中...', mask = true) => {
  if (loadingCount === 0) {
    uni.showLoading({
      title: title,
      mask: mask
    })
  }
  loadingCount++
}

/**
 * 隐藏加载
 * @returns null
 */
const hideLoading = () => {
  if (loadingCount <= 0) return

  loadingCount--
  if (loadingCount === 0) {
    uni.hideLoading();
  }
}

export {
  showLoading,
  hideLoading
}